package cn.idongjia.video;


import cn.idongjia.log.Log;
import cn.idongjia.log.LogFactory;
import org.springframework.util.CollectionUtils;

import java.util.*;


/**
 * Created by dongjia_lj on 16/3/21.
 */
public class VedioConfigLoader {
    private static final Log log = LogFactory.getLog(VedioConfigLoader.class);
    private static VedioConfigLoader onlyone = new VedioConfigLoader();

    private VedioConfigLoader() {

    }

    public static VedioConfigLoader getInstance() {
        return onlyone;
    }

    public Map<String, String> loadConfig() {
        Map<String, String> config = new HashMap<String, String>();
        Properties properties = new Properties();
        try {
            properties.load(this.getClass().getResourceAsStream(Constant.VIDEO_CONFIG_PATH));
            Set keySet = properties.keySet();
            if (!CollectionUtils.isEmpty(keySet)) {
                Iterator iterator = keySet.iterator();
                while (iterator.hasNext()) {
                    String key = (String) iterator.next();
                    String value = (String) properties.get(key);
                    config.put(key, value);
                }
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return config;
    }


}
